package com.regent.central.bill.repository;

import com.regent.central.bill.core.Remittance;
import com.regent.central.bill.core.Remittance;
import com.regent.central.bill.dto.sale_order.SaleOrderDetailRemittanceDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Repository
public interface RemittanceMapper extends Mapper<Remittance> {

    /**
     * 获取销售单的总收/退款
     *
     * @param saleOrderId 销售单ID
     * @return 该销售单的总收/退款
     */
    BigDecimal getAmountArrivedOfSaleOrder(
            @Param("saleOrderId") String saleOrderId
    );

    /**
     * 获取销售单详情的汇款列表
     *
     * @param saleOrderId 销售单ID
     * @return 销售单详情的汇款列表
     */
    List<SaleOrderDetailRemittanceDTO> getSaleOrderDetailRemittances(
            @Param("saleOrderId") String saleOrderId
    );

    /**
     * 更新汇款记录
     *
     * @param remittanceId  汇款记录ID
     * @param remitMethodId 汇款方式ID
     * @param amount        汇款总金额
     * @param dateOperated  汇款时间
     */
    void update(
            @Param("remittanceId") String remittanceId,
            @Param("remitMethodId") String remitMethodId,
            @Param("amount") BigDecimal amount,
            @Param("dateOperated") Date dateOperated
    );

    /**
     * 撤销汇款记录
     *
     * @param remittanceId 汇款记录
     */
    void cancel(
            @Param("remittanceId") String remittanceId,
            @Param("userCanceled") String userCanceled
    );

    /**
     * 获取销售单的汇款记录
     *
     * @param saleOrderId 销售单ID
     * @param canceled    已撤销
     * @param deleted     已删除
     * @return 销售单的汇款记录
     */
    List<Remittance> getSaleOrderRemittances(
            @Param("saleOrderId") String saleOrderId,
            @Param("canceled") Boolean canceled,
            @Param("deleted") Boolean deleted
    );

}